package com.youth.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author yjwu
 * @description 返回结果类。
 * @date 2019/8/14 21:45
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultBean implements Serializable {
    private int code;
    private String msg;
    private Object data;

    public static ResultBean returnInsertSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.SUCCESS_ADD.code, ResultBeanCodeAndMsgEnum.SUCCESS_ADD.msg, data);
    }

    public static ResultBean returnInsertUnSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.ERROR_ADD.code, ResultBeanCodeAndMsgEnum.ERROR_ADD.getMsg(), data);
    }

    public static ResultBean returnDeleteSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.SUCCESS_DELETE.code, ResultBeanCodeAndMsgEnum.SUCCESS_DELETE.getMsg(), data);
    }

    public static ResultBean returnDeleteUnSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.ERROR_DELETE.getCode(), ResultBeanCodeAndMsgEnum.ERROR_DELETE.getMsg(), data);
    }

    public static ResultBean returnUpdateSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.SUCCESS_EDIT.getCode(), ResultBeanCodeAndMsgEnum.SUCCESS_EDIT.getMsg(), data);
    }

    public static ResultBean returnUpdateUnSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.ERROR_EDIT.getCode(), ResultBeanCodeAndMsgEnum.ERROR_EDIT.getMsg(), data);
    }

    public static ResultBean returnSelectSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.SUCCESS_QUERY.getCode(), ResultBeanCodeAndMsgEnum.SUCCESS_QUERY.getMsg(), data);
    }

    public static ResultBean returnSelectUnSuccess(Object data) {
        return new ResultBean(ResultBeanCodeAndMsgEnum.ERROR_QUERY.getCode(), ResultBeanCodeAndMsgEnum.ERROR_QUERY.getMsg(), data);
    }

    public static ResultBean returnNetWorkBusyMsg() {
        return new ResultBean(ResultBeanCodeAndMsgEnum.NETWORK_BUSY.getCode(), ResultBeanCodeAndMsgEnum.NETWORK_BUSY.getMsg(), null);
    }


}
